import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne } from 'typeorm';
import { User } from './User';
import { ListeningMaterial } from './ListeningMaterial';

@Entity('listening_records')
export class ListeningRecord {
  @PrimaryGeneratedColumn()
  id: number;

  @ManyToOne(() => User, user => user.listeningRecords)
  user: User;

  @ManyToOne(() => ListeningMaterial, material => material.listeningRecords)
  material: ListeningMaterial;

  @Column({ type: 'int' })
  score: number;

  @Column({ type: 'int' })
  duration: number;

  @Column({ type: 'json' })
  answers: {
    questionId: number;
    userAnswer: string;
    isCorrect: boolean;
  }[];

  @Column({ type: 'datetime' })
  practiceTime: Date;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;
} 